package com.ruoyi.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AhhcDailySummary;
import com.ruoyi.system.service.IAhhcDailySummaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仅统计当天有数据的患者，补录后自动更新Controller
 *
 * @author ruoyi
 * @date 2025-03-15
 */
@RestController
@RequestMapping("/system/summary")
public class AhhcDailySummaryController extends BaseController
{
    @Autowired
    private IAhhcDailySummaryService ahhcDailySummaryService;

    /**
     * 查询仅统计当天有数据的患者，补录后自动更新列表
     */
    @PreAuthorize("@ss.hasPermi('system:summary:list')")
    @GetMapping("/list")
    public TableDataInfo list(AhhcDailySummary ahhcDailySummary)
    {
        startPage();
        List<AhhcDailySummary> list = ahhcDailySummaryService.selectAhhcDailySummaryList(ahhcDailySummary);
        return getDataTable(list);
    }

    /**
     * 导出仅统计当天有数据的患者，补录后自动更新列表
     */
    @PreAuthorize("@ss.hasPermi('system:summary:export')")
    @Log(title = "仅统计当天有数据的患者，补录后自动更新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AhhcDailySummary ahhcDailySummary)
    {
        List<AhhcDailySummary> list = ahhcDailySummaryService.selectAhhcDailySummaryList(ahhcDailySummary);
        ExcelUtil<AhhcDailySummary> util = new ExcelUtil<AhhcDailySummary>(AhhcDailySummary.class);
        util.exportExcel(response, list, "仅统计当天有数据的患者，补录后自动更新数据");
    }

    /**
     * 获取仅统计当天有数据的患者，补录后自动更新详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:summary:query')")
    @GetMapping(value = "/{patientId}")
    public AjaxResult getInfo(@PathVariable("patientId") String patientId)
    {
        return success(ahhcDailySummaryService.selectAhhcDailySummaryByPatientId(patientId));
    }

    /**
     * 新增仅统计当天有数据的患者，补录后自动更新
     */
    @PreAuthorize("@ss.hasPermi('system:summary:add')")
    @Log(title = "仅统计当天有数据的患者，补录后自动更新", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AhhcDailySummary ahhcDailySummary)
    {
        return toAjax(ahhcDailySummaryService.insertAhhcDailySummary(ahhcDailySummary));
    }

    /**
     * 修改仅统计当天有数据的患者，补录后自动更新
     */
    @PreAuthorize("@ss.hasPermi('system:summary:edit')")
    @Log(title = "仅统计当天有数据的患者，补录后自动更新", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AhhcDailySummary ahhcDailySummary)
    {
        return toAjax(ahhcDailySummaryService.updateAhhcDailySummary(ahhcDailySummary));
    }

    /**
     * 删除仅统计当天有数据的患者，补录后自动更新
     */
    @PreAuthorize("@ss.hasPermi('system:summary:remove')")
    @Log(title = "仅统计当天有数据的患者，补录后自动更新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{patientIds}")
    public AjaxResult remove(@PathVariable String[] patientIds)
    {
        return toAjax(ahhcDailySummaryService.deleteAhhcDailySummaryByPatientIds(patientIds));
    }
}
